# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.action_chains import ActionChains
import unittest
import random
import time
from cookies import lasthopes, randomword
import re
import string
import sys
from selenium.webdriver.common.keys import Keys
from PIL import Image
from os import remove, listdir, sep
from os.path import basename, isfile
import tempfile
from warnings import warn
from basecart import BaseCart

class order_delivery_addr(BaseCart):
    def test_order_delivery_addr(self):
        driver = self.driver
        self.get_cat()
        itm_url = self.get_item()
        #Cart button in left upper corener
        cart_btn = driver.find_element_by_css_selector("div.b-header-top-cell-h > span.b-header-top-cell-anchor")
        self.buy_item()
        #Check for cart button renewed
        WebDriverWait(driver, timeout=10).until(lambda dr: not self.check_exists(cart_btn))
        #If ok go to cart
        self.go_cart()
        self.perform_order()
        #Change city
        newcity = self.change_city()
        delmethod = self.get_delivery(u'Курьер')
        self.select_delivery_tooltip()
        #Fill additional delivery data
        self.fill_shipping_popup(newcity)
        self.catch_bad_popup()
